<template>
	<view>
		<u-navbar :title="$t('关于我们')"></u-navbar>
		<view class="top">
			<image src="http://m-oss.mhbox.top/uploads/20241207/9f7067e1eee659dce51aa2723da6d49f.png" mode="widthFix"></image>
			<view class="rule" @click="show = true">
				{{$t('签到规则')}}
			</view>
		</view>
		<view class="qianbox">
			<view class="listbox">
				<view class="list" :class="idx < num?'active':''" v-for="(item,idx) in list" :key="idx">
					<view class="tit">
						<text>{{$t('第')}}{{item.day}}{{$t('天')}}</text>
						<image src="../../../static/image/qiantit.png" mode=""></image>
					</view>
					<view class="goods">
						<image :src="item.image" mode="widthFix"></image>
					</view>
					<!-- <view class="name" v-if="item.give_type==4">
						{{item.give_type_text}}
					</view>
					<view class="name" v-else>
						{{item.give}}{{item.give_type_text}}
					</view> -->
					<view class="name">
						{{item.give_tip}}
					</view>
					<view class="state">
						{{idx < num? $t('已领取') : $t('未领取')}}
					</view>
				</view>
			</view>
		</view>

		<view class="btn" @click="qian">
			{{$t('点我签到')}}
		</view>

		<u-popup v-model="show" mode="center" border-radius="16">
			<view class="rulebox">
				<view class="ruletit">{{$t('签到领福利规则')}}</view>
				<scroll-view class="scroll" scroll-y>
					<rich-text :nodes="data"></rich-text>
				</scroll-view>
				<view class="btn1" @click="show = false">
					{{$t('确定')}}
				</view>
			</view>

		</u-popup>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				data: '',
				num: '0',
				list: []
			}
		},
		onLoad() {
			uni.loadFontFace({
				family: 'myfont',
				source: 'url("https://m-admin.mhbox.top/YouSheBiaoTiHei.ttf")',
			})
			if (uni.getStorageSync("user")) {
				this.getDat()
				this.getQian()
			}
		},
		onShow() {
			if (!uni.getStorageSync("user")) {
				uni.redirectTo({
					url:'/pages/my/login'
				})
			}
		},
		methods: {
			getQian() {
				this.$http({
					url: "api/member/get_qiandao_set_list",
				}).then(res => {
					console.log(res);
					if (res.data.code == 1) {
						if(res.data.data.sign_day != null){
							this.num = res.data.data.sign_day
						}
						let data = res.data.data.qiandao_set
						this.list = data
					}
				}).catch(err => {});
			},
			qian() {
				// if(this.num == 1)
				this.$http({
					url: "api/member/qiandao",
				}).then(res => {
					console.log(res);
					if (res.data.code == 1) {
						this.$tip.tip(res.data.msg)
						this.getQian()
					} else {
						this.$tip.tip(res.data.msg)
					}
				}).catch(err => {});
			},
			getDat(type) {
				this.$http({
					url: "api/common/get_agreement",
					data: {
						name: 'qiandao_rule'
					}
				}).then(res => {
					if (res.data.code == 1) {
						this.data = res.data.data.content

					} else {
						this.$tip.tip(res.data.msg)
					}
				}).catch(err => {});
			}
		}
	}
</script>

<style>
	@import url("../../static/qiandao.css");
</style>
